<script>
init({
  title: 'Aligning Footer',
  desc: 'Use `falign` to set the alignment of the columns in the footer.',
  links: ['bootstrap-table.min.css'],
  scripts: ['bootstrap-table.min.js']
})
</script>

<template>
  <table
    id="table"
    data-toggle="table"
    data-height="460"
    data-show-footer="true"
    data-url="json/data1.json"
  >
    <thead>
      <tr>
        <th
          data-field="id"
          data-falign="left"
          data-footer-formatter="idFormatter"
        >
          ID
        </th>
        <th
          data-field="name"
          data-falign="center"
          data-footer-formatter="nameFormatter"
        >
          Item Name
        </th>
        <th
          data-field="price"
          data-falign="right"
          data-footer-formatter="priceFormatter"
        >
          Item Price
        </th>
      </tr>
    </thead>
  </table>
</template>

<script>
  window.idFormatter = () => 'Total'
  window.nameFormatter = data => data.length
  window.priceFormatter = data => `$${data.map(row => +row.price.substring(1)).reduce((sum, i) => sum + i, 0)}`
</script>
